The Fireworks Integration API > The Fireworks integration API > FWLaunch.getJsResponse()

 

FWLaunch.getJsResponse()

Availability

Dreamweaver 3.0, Fireworks 3.0

Description

Determines whether Fireworks is still executing the JavaScript passed to it by FWLaunch.execJsInFireworks(), whether the script completed successfully, or whether an error occurred.

Arguments

progressTrackerCookie

The argument is the cookie object returned by FWLaunch.execJsInFireworks().

Returns

A string containing the result of the script passed to FWLaunch.execJsInFireworks() if the operation completed successfully, null if Fireworks is still executing the JavaScript, or a nonzero error code indicating that one of the following errors occurred:

1: Invalid usage; a JavaScript error occurred as Fireworks was executing the script.
2: File I/O error; Fireworks is unable to create a Response file because the disk is full.
3: Error notifying Dreamweaver; the user is not running a valid version of Dreamweaver (3.0 or later).
4: Error launching Fireworks process; the function did not launch a valid version of Fireworks (3.0 or later).
5: User cancelled the operation.

Returns

The following code passes the string "prompt('Please enter your name:')" to FWLaunch.execJsInFireworks() and then checks for the result:

var progressCookie = FWLaunch.execJsInFireworks("prompt('Please ¬
enter your name:')");
var doneFlag = false;
while (!doneFlag){
	// check for completion every 1/2 second
	setTimeout('checkForCompletion()',500);
}

function checkForCompletion(){
	if (progressCookie != null) {
		var response = FWLaunch.getJsResponse(progressCookie);
		if (response != null) {
			if (typeof(response) == "number") {
				// error or user-cancel, time to close the window
				// and let the user know we got an error
				window.close();
				alert("An error occurred.");
			}else{
				// got a valid response!
				alert("Nice to meet you, " + response);
				window.close();
			}
				doneFlag = true;
		}
	}
}